<template>
  <el-container class="layout-container-demo" style="height: 500px">
    <el-header style="text-align: right; font-size: 12px">
      <div class="toolbar">
        <el-text style="margin-right: 1200px; color: white;">企业人事管理平台</el-text>
        <el-button @click="router.push('/empInfo')" style="margin-right: 10px;"><el-icon><UserFilled /></el-icon>&nbsp;&nbsp;{{ empInfo?.empname }}</el-button>
        <el-button @click = "doLogout"><el-icon><SwitchButton /></el-icon>&nbsp;&nbsp;注销</el-button>
      </div>
    </el-header>
    <el-container>
      <el-aside width="200px">
        <el-scrollbar>
          <el-menu router text-color="white" background-color="grey" :default-openeds="['']">
            <el-menu-item index="/main">首页</el-menu-item>
            <el-menu-item index="/empinfo">查看个人信息</el-menu-item>
            <el-menu-item index="/changePassword">修改登录密码</el-menu-item>
            <el-sub-menu index="1">
              <template #title>
                时间管理
              </template>
              <el-menu-item index="/attend">考勤打卡</el-menu-item>
              <el-menu-item v-if="empInfo?.authority_id == 2" index="/approveAttend">审批考核补签</el-menu-item>
              <el-menu-item index="/app4vocation">申请休假</el-menu-item>
              <el-menu-item index="/vocationlist">休假记录</el-menu-item>
              <el-menu-item v-if="empInfo?.authority_id == 3" index="/approveVocation">审批休假</el-menu-item>
              <el-menu-item index="/approverlist" v-if="empInfo?.authority_id == 1">审批人设定</el-menu-item>
              <el-menu-item index="/empworktype" v-if="empInfo?.authority_id == 1">人员排班设定</el-menu-item>
              <el-menu-item index="/worktype" v-if="empInfo?.authority_id == 1">排班类型设定</el-menu-item>
              <el-menu-item index="/vocationtype" v-if="empInfo?.authority_id == 1">假期类型设定</el-menu-item>
            </el-sub-menu>
            <el-menu-item index="/emplist">员工信息管理</el-menu-item>
            <el-menu-item index="/deptlist">部门信息管理</el-menu-item>
            <el-menu-item index="/position">职位信息管理</el-menu-item>
          </el-menu>
        </el-scrollbar>
      </el-aside>

      <el-main>
        <el-scrollbar>
          <RouterView/>
        </el-scrollbar>
      </el-main>
    </el-container>
  </el-container>
</template>

<script name='Home' setup lang='ts'>
import { useRouter } from 'vue-router';
import { useEmpStore } from '../store/emp';
import { storeToRefs } from 'pinia';

const router = useRouter()
function doLogout(){
  localStorage.removeItem('token')
  router.push({ path: '/LoginE' })
}

const store = useEmpStore()
const { empInfo } = storeToRefs(store)
empInfo.value?.authority_id

</script>

<style scoped>
.layout-container-demo {
  /* height: 100vh !important; */
}

.layout-container-demo .el-header {
  position: relative;
  background-color: grey;
  color: white;
}

.layout-container-demo .el-aside {
  color: white;
  background: grey;
}

.layout-container-demo .el-menu {
  border-right: none;
}

.layout-container-demo .el-main {
  padding: 0;
}

.layout-container-demo .toolbar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  right: 20px;
}
</style>
